package com.zwh.modbus.netty.modbus.tcp.netty;


import com.zwh.modbus.netty.modbus.tcp.handler.TCPModbusReqEncoder;
import com.zwh.modbus.netty.modbus.tcp.handler.TCPModbusResDecoder;
import org.springframework.stereotype.Component;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * Created with IntelliJ IDEA.
 * User: linghufeixia
 * Date: 2022-12-1
 * Description: channel初始化器
 */
@Component
public class TCPServerChannelInitializer extends ChannelInitializer<SocketChannel> {

    public TCPServerChannelInitializer() {
        super();
    }

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline().addLast("decoder", new TCPModbusResDecoder());
        socketChannel.pipeline().addLast("encoder", new TCPModbusReqEncoder());
//        socketChannel.pipeline().addLast("tcpModbus", new TCPModbusResHandler());
    }
}
